<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增车辆列')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-carList-add">
            <h4 class="form-header h4">车辆列信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">车辆名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">车辆颜色：</label>
                <div class="col-sm-8">
                    <input name="color" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">车牌号：</label>
                <div class="col-sm-8">
                    <input name="card" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">司机：</label>
                <div class="col-sm-8">
<!--                    <input name="driver" class="form-control" type="text">-->
                    <select name="driver" id="driver" class="form-control" >
                        <option th:each="item,info:${user}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
<!--                    <input name="status" class="form-control" type="text">-->
                    <select name="status" id="status" class="form-control">
                        <option value="正常">正常</option>
                        <option value="外借">外借</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建人id：</label>
                <div class="col-sm-8">
                    <input name="creater" class="form-control" th:value="${sysUser.userId}"  type="hidden">
                    <span th:text="${sysUser.userName}"></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="createdTime" class="form-control createdTime" disabled placeholder="自动获取当前时间" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="text" class="form-control"></textarea>
                </div>
            </div>
           <!-- <h4 class="form-header h4">人员信息信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/carList"
        $("#form-carList-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            $('.createdTime').val(getNowTime())
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-carList-add').serialize());
            }
        }

        $("input[name='createdTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        //获取当前时间
        function getNowTime() {
            var date = new Date();
            //年 getFullYear()：四位数字返回年份
            var year = date.getFullYear();  //getFullYear()代替getYear()
            //月 getMonth()：0 ~ 11
            var month = date.getMonth() + 1;
            //日 getDate()：(1 ~ 31)
            var day = date.getDate();
            //时 getHours()：(0 ~ 23)
            var hour = date.getHours();
            //分 getMinutes()： (0 ~ 59)
            var minute = date.getMinutes();
            //秒 getSeconds()：(0 ~ 59)
            var second = date.getSeconds();

            var time = year + '-' + addZero(month) + '-' + addZero(day) + ' ' + addZero(hour) + ':' + addZero(minute) + ':' + addZero(second);
            return time;
        }


        //小于10的拼接上0字符串
        function addZero(s) {
            return s < 10 ? ('0' + s) : s;
        }

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'deptId',
                    align: 'center',
                    title: '部门ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].deptId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'loginName',
                    align: 'center',
                    title: '登录账号',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].loginName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'userName',
                    align: 'center',
                    title: '人员姓名',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].userName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'userType',
                    align: 'center',
                    title: '用户类型',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].userType' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'email',
                    align: 'center',
                    title: '用户邮箱',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].email' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'phonenumber',
                    align: 'center',
                    title: '手机号码',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].phonenumber' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'sex',
                    align: 'center',
                    title: '用户性别',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].sex' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'avatar',
                    align: 'center',
                    title: '头像路径',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].avatar' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'password',
                    align: 'center',
                    title: '密码',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].password' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'salt',
                    align: 'center',
                    title: '盐加密',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].salt' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'status',
                    align: 'center',
                    title: '帐号状态',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].status' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'delFlag',
                    align: 'center',
                    title: '删除标志',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].delFlag' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'loginIp',
                    align: 'center',
                    title: '最后登录IP',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].loginIp' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'loginDate',
                    align: 'center',
                    title: '最后登录时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].loginDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'pwdUpdateDate',
                    align: 'center',
                    title: '密码最后更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].pwdUpdateDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createBy',
                    align: 'center',
                    title: '创建者',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].createBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateBy',
                    align: 'center',
                    title: '更新者',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].updateBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'endTime',
                    align: 'center',
                    title: '结束时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].endTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'remark',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].remark' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'withWork',
                    align: 'center',
                    title: '协同人',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].withWork' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'dest',
                    align: 'center',
                    title: '目的地',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].dest' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'reason',
                    align: 'center',
                    title: '原因',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].reason' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'state',
                    align: 'center',
                    title: '状态',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysWzxUserList[%s].state' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                deptId: "",
                loginName: "",
                userName: "",
                userType: "",
                email: "",
                phonenumber: "",
                sex: "",
                avatar: "",
                password: "",
                salt: "",
                status: "",
                delFlag: "",
                loginIp: "",
                loginDate: "",
                pwdUpdateDate: "",
                createBy: "",
                createTime: "",
                updateBy: "",
                updateTime: "",
                endTime: "",
                remark: "",
                withWork: "",
                dest: "",
                reason: "",
                state: "",
            }
            sub.addRow(row);
        }
    </script>
</body>
</html>